package com.ktvme.MqTest

import groovy.json.JsonOutput
import org.apache.commons.lang3.RandomStringUtils
import org.apache.commons.lang3.RandomUtils

/**
 * @author fanwu 编写于 2017/12/27.
 */
@Singleton
class RoomStateHelper {
    static Map generateRandomRoomState() {
        def roomInfo = [destinetime    : "", opentime: "22:21", closedatetime: "", testmin: 0, roomthemeid: 2,
                        roomthemename  : "Fucking Test", gradename: " ", lookmin: 0, checkoutmode: 2, destineremark: "",
                        datadealstate  : 2, lownesscharge: 0, guestname: "", roomcallflag: 0,
                        remindflag     : 0, hourcharge: 22, iskm: 0, opendatetime: "2017-08-09 16:21:41",
                        winecharge     : 7729.2, reminddate: " ", guestnumber: "(2)", hasmemberbirthday: 0, destinedatetime: " ", lunarflag: 0
                        , memberid     : 1, areaname: "测试区", roomstatename: "使用", areaid: 2, consumemode: 0, checkoutdatetime: "",
                        sellmanagername: "", roompricesortname: "Fuck包", uncheckflag: 1, printlockflag: 0, buffet: 0,
                        managestyleid  : -1, calltype: 0, checkouttime: " ", birthdate: "", businessmode: 1, roomcharge: 200,
                        roompricesortid: 1, roomstate: 5, buybreak: 0, destinename: "", hourlowness: 0, modename: "包厢费+钟点费",
                        endtime        : "", presentflag: 0]
        def roomName = RandomStringUtils.randomAlphabetic(1) + RandomStringUtils.randomNumeric(3)
        def checkoutMoney = MoneyUtil.convertFen2Yuan(RandomUtils.nextInt(1, 60000))
        def uncheckoutMoney = MoneyUtil.convertFen2Yuan(RandomUtils.nextInt(1, 60000))
        def roomID = RandomStringUtils.randomNumeric(3)
        def voucher = RandomStringUtils.randomAlphabetic(14)
        return roomInfo << [roomname           : roomName, roomid: roomID, checkoutwinemoney: checkoutMoney,
                            uncheckoutwinemoney: uncheckoutMoney, checkoutvoucher: voucher]
    }

    static List<Map> genRoomStates(int roomNum) {
        List<Map> data = new ArrayList<>(roomNum)
        for (int i = 0; i < roomNum; ++i) {
            data.add(generateRandomRoomState())
        }
        return data
    }

    static void main(String[] args) {
        def room = generateRandomRoomState()
        println "room = $room"

        List<Map> data = genRoomStates(1000)
        String json = JsonOutput.toJson(data)
        println "json = $json"
    }
}
